<template>
  <view>
    <form @submit.prevent="onSubmit" @reset="formReset">
      <view>
        <view>施工申请单id:</view>
        <input type="text" name="formId" v-model="formData.formId" placeholder="请输入施工申请单id" />
      </view>

      <view>
        <view>令号:</view>
        <input type="text" name="formCode" v-model="formData.formCode" placeholder="请输入令号" />
      </view>
	  
	  <view>
	    <view>星期:</view>
	    <input type="text" name="dayOfWeek" v-model="formData.dayOfWeek" placeholder="请输入星期" />
	  </view>
	  
	  <view>
	    <view>班组:</view>
	    <input type="text" name="workTeam" v-model="formData.workTeam" placeholder="请输入班组" />
	  </view>
	  
	  <view class="uni-title uni-common-pl" >线路：</view>
	  <view class="uni-list">
	  	<view class="uni-list-cell">
	  		<view class="uni-list-cell-left">
	  					
	  		</view>
	  		<view class="uni-list-cell-db">
	  			<picker @change="bindPickerChange2" :value="index2" :range="array2" v-model="formData.line" name="line">
	  				<view class="uni-input">{{array2[index2]}}</view>
	  			</picker>
	  		</view>
	  	</view>
	  </view>
	  
	  <view>
	    <view>申请单工作内容:</view>
	    <input type="text" name="workContentRequest" v-model="formData.workContentRequest" placeholder="请输入申请单工作内容" />
	  </view>
	  
	  <view>
	    <view>工作负责人:</view>
	    <input type="text" name="workLeader" v-model="formData.workLeader" placeholder="请输入工作负责人" />
	  </view>
	  
	  <view>
	    <view>作业点负责人:</view>
	    <input type="text" name="workPointLeader" v-model="formData.workPointLeader" placeholder="请输入作业点负责人" />
	  </view>
	  
	  <view>
	    <view>作业点负责人数:</view>
	    <input type="text" name="workPointLeaderCount" v-model="formData.workPointLeaderCount" placeholder="请输入作业点负责人数" />
	  </view>
	  
	  <view>
	    <view>作业班人员:</view>
	    <input type="text" name="workTeamMembers" v-model="formData.workTeamMembers" placeholder="请输入作业班人员" />
	  </view>
	  
	  <view>
	    <view>作业班人数:</view>
	    <input type="text" name="workTeamMemberCount" v-model="formData.workTeamMemberCount" placeholder="请输入作业班人数" />
	  </view>
	  
	  <view>
	    <view>总作业人数:</view>
	    <input type="text" name="totalWorkforce" v-model="formData.totalWorkforce" placeholder="请输入总作业人数" />
	  </view>
	  
	  <view>
	    <view>作业区段:</view>
	    <input type="text" name="workSection" v-model="formData.workSection" placeholder="请输入作业区段" />
	  </view>
	  
	  <view>
	    <view>实际作业详情:</view>
	    <input type="text" name="actualWorkDetails" v-model="formData.actualWorkDetails" placeholder="请输入实际作业详情" />
	  </view>
	  
	  <view>
	    <view>数量:</view>
	    <input type="text" name="quantity" v-model="formData.quantity" placeholder="请输入数量" />
	  </view>
	  
	  <view>
	    <view>计量器具:</view>
	    <input type="text" name="measuringInstruments" v-model="formData.measuringInstruments" placeholder="请输入计量器具" />
	  </view>
	  
	  <view>
	    <view>安装/更换的设备:</view>
	    <input type="text" name="installedReplacedEquipment" v-model="formData.installedReplacedEquipment" placeholder="请输入安装/更换的设备" />
	  </view>
	  
	  <view>
	    <view>物资消耗:</view>
	    <input type="text" name="materialConsumption" v-model="formData.materialConsumption" placeholder="请输入物资消耗" />
	  </view>
	  
	  <view>
	    <view>设备隐患:</view>
	    <input type="text" name="equipmentHazards" v-model="formData.equipmentHazards" placeholder="请输入设备隐患" />
	  </view>
	  
	  <view>
	    <view>备注:</view>
	    <input type="text" name="remak" v-model="formData.remak" placeholder="请输入备注" />
	  </view>
	  
	  
	  <view>
	          <button form-type="submit" type="primary">提交表单</button>
	          <button form-type="reset">重置表单</button>
	        </view>
	      </form>
	    </view>
	  </template>

<script>
import axios from "axios";

export default {
  data() {
    return {
		array2: ['十七号线','十三号线'],
		index2: 0,
      formData: {
                formId:"",
        		formCode:'',
                dayOfWeek: "",
                workTeam: "",
                line: "",
                workPointLeader: "",
                workPointLeaderCount: "",
                workTeamMembers: "",
                workTeamMemberCount: "",
                totalWorkforce: "",
                workSection: "",
                actualWorkDetails: "",
                quantity: "",
                measuringInstruments: "",
                installedReplacedEquipment: "",
                materialConsumption: "",
                equipmentHazards: "",
                remak: "",
      }
    };
  },
  methods: {
	  bindPickerChange2: function(e) {
	             console.log('picker发送选择改变，携带值为', e.detail.value)
	             this.index2 = e.detail.value
	  		   this.formData.line = this.index2
	  		   console.log(this.formData);
	         },
    onSubmit(e) {
      e.preventDefault(); // 阻止默认表单提交
      console.log(this.formData); // 打印表单数据
      axios.post("http://localhost:82//periodJobSummary/management", this.formData)
        .then(response => {
          console.log(response.data);
		  uni.navigateTo({
		              url: '/pages/constructionprocess/constructionprocess?update7=true'
		            });
          // 处理返回的数据
        })
        .catch(error => {
          console.error(error);
          // 处理错误
        });
    },
    formReset() {
      this.formData = {};
    }
  }
};
</script>

<style lang="scss">
  input, textarea {
    border: 1px solid #eee;
  }
  form {
    padding: 20rpx;
  }
  view {
    margin-bottom: 20rpx;
  }
</style>